package ch.fusun.baron.property.api;

import java.util.List;
import java.util.Map;

import ch.fusun.baron.data.DataProvider;

/**
 * Service to handle all property
 */
public interface PropertyService extends DataProvider {

	/**
	 * @param owned
	 *            is the object owned by someone?
	 * @return true iff owned
	 */
	boolean isOwned(Object owned);

	/**
	 * @param owner
	 *            The new owner
	 * @param owned
	 *            the object to be owned by the owner
	 */
	void setOwnership(Object owner, Object owned);

	/**
	 * @param owned
	 *            The object
	 * @return The owner of the object
	 */
	Object getOwnership(Object owned);

	/**
	 * @param owner
	 *            The owner
	 * @param clazz
	 *            The type of the owned
	 * @return The list of objects owned by the owner of class clazz
	 */
	<T> List<T> getAllOwnerships(Object owner, Class<T> clazz);

	/**
	 * @param owner
	 *            The owner class
	 * @param owned
	 *            The type of the owned
	 * @return The list of objects owned by the owner of class owned
	 */
	<S, T> Map<S, List<T>> getAllOwnerships(Class<S> owner, Class<T> owned);

}
